package com.party.poster;


import com.party.common.config.RuoYiConfig;
import com.party.poster.draw.PosterDefaultDraw;
import com.party.poster.entity.SamplePoster;
import com.party.poster.enums.EnumShape;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;

public class Test {

    public static void main(String[] args)throws Exception {

        String ce = Test.class.getClassLoader().getResource("ce.jpg").getPath();//获取文件路径
        String a200 ="E:/touxiang.png";//获取文件路径
        String a159 = "E:/kkk/159.png";//获取文件路径

        BufferedImage headImg = ImageIO.read(new File(ce));
        BufferedImage avatarImg = ImageIO.read(new File(a200));
        BufferedImage qr = ImageIO.read(new File(a159));
        SamplePoster samplePoster = SamplePoster.build()
                .canvas(670,1307, Color.WHITE)
                .img(670,900,headImg)
                .graphical(540,800,80,60,Color.white, EnumShape.RoundedRectangle,50,100)
                .img(120,120,300,10,avatarImg, EnumShape.Circular)
                .img(150,150,300,600,qr,EnumShape.None)
                .text("张三",320,170,new Font("微软雅黑", Font.LAYOUT_NO_START_CONTEXT, 25),Color.black)
                .text("电话：15054115351",130,330,new Font("微软雅黑", Font.LAYOUT_NO_START_CONTEXT, 25),Color.black)
                .text("邮箱：11645003208@qq.com",130,370,new Font("微软雅黑", Font.LAYOUT_NO_START_CONTEXT, 25),Color.black)
                .text("地址：济南市天桥区汽车厂",130,410,new Font("微软雅黑", Font.LAYOUT_NO_START_CONTEXT, 25),Color.black)
                .text("您好，我是上海沪力建筑工程有限公司",100,500,new Font("微软雅黑", Font.LAYOUT_NO_START_CONTEXT, 25),Color.black)
                .text("的黄邹明请收下我的名片，谢谢",100,540,new Font("微软雅黑", Font.LAYOUT_NO_START_CONTEXT, 25),Color.black)
                .text("长按查看",330,800,new Font("微软雅黑", Font.LAYOUT_NO_START_CONTEXT, 25),Color.lightGray);
//                .text("875人觉得本文很精彩",30,1230,new Font("微软雅黑", Font.LAYOUT_NO_START_CONTEXT, 30),Color.lightGray)
//                .graphical(100,60,0,1100,Color.YELLOW)
//                .text("上市 | 旅行笔记",30,1150,new Font("微软雅黑", Font.CENTER_BASELINE, 35),Color.BLACK)
//                .text("\"我叫小猪666\"的旅行笔记",30,950,new Font("微软雅黑", Font.LAYOUT_NO_LIMIT_CONTEXT, 30),Color.BLACK)
//                .text("上海哪拍最出片 上海周末玩什么  上海美食探店",30,1000,new Font("微软雅黑", Font.LAYOUT_NO_START_CONTEXT, 25),Color.lightGray);

        BufferedImage image = PosterDefaultDraw.draw(samplePoster);
        ImageIO.write(image, "jpg", new File("E:/poster.jpg"));

        //圆角的透明矩形
        //RoundRectangle2D roundedRectangle = new RoundRectangle2D.Float(100, 100, 240, 160, 10, 10);
        //g2.draw(roundedRectangle);
    }

}
